package com.zyf.heixiang.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author DL5O
 * @version 1.0
 * mybatis-plus配置类
 */
@Configuration
public class MybatisPlusConfig {

   //把MybatisPlusInterceptor 做成bean交给spring管理
   @Bean
   public MybatisPlusInterceptor mybatisPlusInterceptor(){
      MybatisPlusInterceptor mpInterceptor = new MybatisPlusInterceptor();
      mpInterceptor.addInnerInterceptor(new PaginationInnerInterceptor());//增加分页拦截器
      mpInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());//增加乐观锁拦截器
      return mpInterceptor;
   }
}
